import deepCopy from '../../../functions/deep-copy';

const showItems = ['pk_psndoc.code', 'pk_psndoc.name', 'batchdept'];

const batchAddSubTemplate = 'batchAddSub';
const batchAddSubTaleTemplate = 'batchAddSubTaleTemplate';

export default function(data) {
    const {
        currentForm
    } = this.state;

    const {
        editTable: {
            createEditTable,
            setStatus,
            setTableData
        },
        meta: {
            getMeta,
            setMeta
        }
    } = this.props;

    if(!currentForm) {
        return null;
    }

    let template = getMeta();
    template[batchAddSubTaleTemplate] = deepCopy(template[currentForm]);
    template[batchAddSubTaleTemplate].items.map((item) => {
        if(showItems.includes(item.attrcode)) {
            item.visible = true;
        }
    }); 
    
    setStatus(batchAddSubTaleTemplate, 'edit');
    setTableData(batchAddSubTaleTemplate, data);
    setMeta(template);
}
